<template>
	<view class="page">
		<view class="my-top">
			<!-- head -->
			<view class="head" :style="'background-color: rgba(255,255,255,'+(scrollTop/50)+');'">
				<view class="portrait">
					<image v-show="scrollTop>20" :src="storeInfo.logo_img">
					</image>
				</view>
				<view class="title">
					<text v-show="scrollTop>20">我的</text>
				</view>

			</view>
			<!-- 用户信息 -->

			<view class="user-info">
				<view class="portrait">
					<image
						src="https://tse1-mm.cn.bing.net/th/id/OIP-C.6pnn3ujxU-vjTdGP4zJhPwHaLE?w=126&h=188&c=7&r=0&o=5&pid=1.7">
					</image>
				</view>
				<view class="info">
					<view class="nickname">
						<text>{{storeInfo.store_name}}</text>

					</view>
				</view>
			</view>
			<!-- 发货区 -->
			<view class="focus-area">
				<view class="list" @click="onSkipOrder(1)">
					<view class="num">
						<text>0</text>
					</view>
					<view class="title">
						<text>待付款</text>
					</view>
				</view>
				<view class="list" @click="onSkipOrder(2)">
					<view class="num">
						<text>{{storeInfo.pendingShopNnum}}</text>
					</view>
					<view class="title">
						<text>代发货</text>
					</view>
				</view>
				<view class="list" @click="order1">
					<view class=" num">
						<text>{{storeInfo.refundShopNnum}}</text>
					</view>
					<view class="title">
						<text>售后订单</text>
					</view>
				</view>
			</view>

		</view>
		<!-- 我的服务 -->
		<view class="my-service">
			<view class="title">
				<text style="font-size: 36rpx; font-weight: bold; color: #212121;">常用应用</text>
			</view>
			<view class="service-list">
				<view class="list" v-if="nav_id == 1||nav_id ==5 || nav_id==8" @click="onServer('paipin1')">
					<view class="thumb">
						<image src="http://140.143.146.33/wxImg/static/icon/shangchuan.png">
						</image>
					</view>
					<view class="name">
						<text>拍品上传</text>
					</view>
				</view>
				<view class="list" v-if="nav_id == 1||nav_id ==5 || nav_id==8" @click="onServer('paipin2')">
					<view class="thumb">
						<image src="http://140.143.146.33/wxImg/static/icon/shangchuan.png">
						</image>
					</view>
					<view class="name">
						<text>我的拍品</text>
					</view>
				</view>
				<view class="list" v-if="" @click="onServer('addShop')">
					<view class="thumb">
						<image src="http://140.143.146.33/wxImg/static/icon/tianjiashangpin.png"></image>
					</view>
					<view class="name">
						<text>添加商品</text>
					</view>
				</view>
				<view class="list" @click="onServer('shangjia')">
					<view class="thumb">
						<image src="http://140.143.146.33/wxImg/static/icon/tianjiashangpin.png"></image>
					</view>
					<view class="name">
						<text>编辑上架商品</text>
					</view>
				</view>
				<view class="list" v-if="nav_id == 1||nav_id ==5 || nav_id==8" @click=" onServer('order1')">
					<view class="thumb">
						<image src="http://140.143.146.33/wxImg/static/icon/paimaidingdan1.png"></image>
					</view>
					<view class="name">
						<text>拍卖订单</text>
					</view>
				</view>
				<view class="list" @click="savePaySort">
					<view class="thumb">
						<image src="http://140.143.146.33/wxImg/static/icon/paimingkaoqian-01.png"></image>
					</view>
					<view class="name">
						<text>自助靠前</text>
					</view>
				</view>
				<!-- <view class="list" @click="onServer('upload')">
					<view class="thumb">
						<image src="http://140.143.146.33/wxImg/static/icon/24px.png"></image>
					</view>
					<view class="name">
						<text>上传精品</text>
					</view>
				</view> -->
				<view class="list" @click="onServer('orderManagement')">
					<view class="thumb">
						<image src="http://140.143.146.33/wxImg/static/icon/dingdanguanli.png"></image>
					</view>
					<view class="name">
						<text>订单管理</text>
					</view>
				</view>
				<view class="list" @click="onServer('setting')">
					<view class="thumb">
						<image src="http://140.143.146.33/wxImg/static/icon/shanghushezhi.png"></image>
					</view>
					<view class="name">
						<text>商户设置</text>
					</view>
				</view>
				<view class="list" @click="onServer('message')">
					<view class="thumb">
						<image src="http://140.143.146.33/wxImg/static/icon/xiaoxizhongxin.png"></image>
					</view>
					<view class="name">
						<text>消息中心</text>
					</view>
				</view>


			</view>
		</view>
		<!-- 今日商城数据 -->
		<view class="data">
			<view class="title">
				<text style="font-size: 36rpx; font-weight: bold; color: #212121;">商城今日数据：</text>
			</view>
			<view class="data-list">
			
				<view class="list">
					<view class="thumb">
						{{storeInfo.pendingShopNnum}}
					</view>
					<view class="name">
						待发货
					</view>
				</view>
				<view class="list">
					<view class="thumb">
						{{storeInfo.refundShopNnum}}
					</view>
					<view class="name">
						售后订单
					</view>
				</view>
				<view class="list">
					<view class="thumb">
						{{storeInfo.views_number}}
					</view>
					<view class="name">
						浏览人数
					</view>
				</view>
			

			</view>
		</view>


	</view>
</template>

<script>
	import {
		getUserStoreInfo,
		savePaySort,
		delNameById,
		getLSpaySort
	} from '@/config/api.js';
	export default {

		data() {
			return {
				storeInfo: {},
				scrollTop: 0,
				nav_id: uni.getStorageSync('pathNavId'),
				store_id:  uni.getStorageSync('pathStoreId'),
				show: false,

				show1: false,
			};
		},
		onReady() {
			uni.hideTabBar();
			getUserStoreInfo({
				nav_id: uni.getStorageSync('pathNavId'),
				store_id: uni.getStorageSync('pathStoreId')
			}).then(res => {
				this.storeInfo = res;
			})
		},
		onPageScroll(e) {
			this.scrollTop = e.scrollTop;
		},
		methods: {
			savePaySort(){
				const _this = this;
				uni.showModal({
					title: '确认付费提升排名？',
					success: function(res) {
						if (res.confirm) {
							getLSpaySort({
								nav_id: _this.nav_id
							}).then(data => {
								if(data.signType){
									wx.requestPayment({
									  timeStamp: data.timeStamp,
									  nonceStr: data.nonceStr,
									  package: data.package,
									  signType: data.signType,
									  paySign: data.paySign,
									  success (res) { 
										  savePaySort({
											  nav_id: _this.nav_id,
											  store_id: _this.store_id
										  }).then(res => {
											  console.log(res,'=============')
											  uni.$u.toast('操作成功!')
										  })
									  },
									  fail (res) { 
										  // 支付失败 删除商品
										  delNameById({order_sn: data._order_sn})
									  }
									})
								}
							})
						}
					}
				});
			},
			// 订单
			onSkipOrder(type) {

				uni.navigateTo({
					url: '/moduleD/hongShanHun/orderManagement/orderManagement?type=' + type,
				})
			},





			/**
			 * 我的服务点击
			 */
			onServer(type) {
				uni.setStorageSync('goodsId', '')
				switch (type) {
					case 'paipin1':
						uni.navigateTo({
							url: '/moduleD/hongShanHun/addShop/paipin'
						})
						break;
					case 'paipin2':
						uni.navigateTo({
							url: '/moduleD/hongShanHun/shangjia/paipin'
						})
						break;
					case 'paipin':
						uni.navigateTo({
							url: '/moduleD/hongShanHun/paipin/paipin',
						})
						break;
					case 'addShop':
						uni.navigateTo({
							url: '/moduleD/hongShanHun/addShop/addShop'
						})
						break;
					case 'shangjia':
						uni.navigateTo({
							url: '/moduleD/hongShanHun/shangjia/shangjia'
						})
						break;
					case 'order1':
						uni.navigateTo({
							url: `/moduleD/paiMai/paiMai?store_id=${this.store_id}&nav_id=${this.nav_id}`,
						})
						break;

					case 'stepForward':
						uni.navigateTo({
							url: '/moduleD/hongShanHun/stepForward/stepForward'
						})
						break;

					case 'upload':
						uni.navigateTo({
							url: '/moduleD/hongShanHun/uploadBest/uploadBest'
						})
						break;
					case 'orderManagement':
						uni.navigateTo({
							url: '/moduleD/hongShanHun/orderManagement/orderManagement'
						})
						break;
					case 'setting':
						uni.navigateTo({
							url: '/moduleD/hongShanHun/setting/setting'
						})
						break;
					case 'message':
						uni.navigateTo({
							url: '/moduleD/hongShanHun/message/message'
						})
						break;

				}
			},


			onUserInfo() {
				uni.navigateTo({
					url: '/pages/login/login'
				})
			},
			hongShanHun() {
				uni.navigateTo({
					url: '/pages/login/login'
				})
			},
			yanJiuHui() {

			}
		}
	}
</script>

<style scoped lang="scss">
	@import 'hongShanHun.scss';
</style>